import os
if os.path.exists("D:\\test\\a.txt"):
    os.remove("D:\\test\\a.txt")
    os.rmdir("D:\\test")
os.mkdir("D:\\test")
file = open("D:\\test\\a.txt", "w", -1, "utf-16")
content = input("请输入要写入的内容: ")
file.writelines(content + "\n")
file.close()
file = open("D:\\test\\a.txt", "a", -1, "utf-16")
file.write("Hello Python!")
file.close()
file = open("D:\\test\\a.txt", "r", -1, "utf-16")
for line in file:
    print(line)
file.close()